<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .div1 {
            background-size: 100vw 100vh;
            background-color: red;
        }

        .div2 {
            background-size: 100vw 100vh;
            background-color: blue;
        }

        .div3 {
            background-size: 100vw 100vh;
            background-color: black;
        }

        .div4 {
            background-size: 100vw 100vh;
            background-color: green;
        }
    </style>
</head>

<body>
    <div class="div"></div>
    <button>我带你们打</button>
    <script>
        var getdiv = document.querySelector("div")
        var btn = document.querySelector("button")
        var num;
        btn.onclick = function(){
        function xx(min, max) {
                var num = parseInt(Math.random() * (max + 1 - min) + min)  
                return num
            }
            var sri = xx(0,10)
            if (sri < 3) {
                document.body.className = "div1"
            } else if (sri < 5 && sri >= 3) {
                document.body.className = "div2"
            } else if (sri >= 5 && sri < 7) {
                document.body.className = "div3"
            } else {
                document.body.className = "div4"
            }
        }
    </script>
</body>

</html>